<!DOCTYPE html>
<html>
<head>
    <title>设备故障库</title>
    #parse("sys/header.html")
</head>
<body>
<div>
    <table id="jqGrid"></table>
</div>
<script>
    $(function () {
        $("#jqGrid").Grid({
            url: '../faultbase/list',
            colModel: [
                {label: '故障大类名称', name: 'devTypeNameB', index: 'DEV_TYPE_NAME_B', width: 80},
                {label: '故障中类名称', name: 'devTypeNameM', index: 'DEV_TYPE_NAME_M', width: 80},
                {label: '故障小类名称', name: 'devTypeNameS', index: 'DEV_TYPE_NAME_S', width: 80},
                {label: '故障类型', name: 'faultType', index: 'FAULT_TYPE', width: 80},
                {label: '故障代码', name: 'faultCode', index: 'FAULT_CODE', width: 80},
                {label: '故障原因', name: 'faultReason', index: 'FAULT_REASON', width: 80},
                {
                    label: '类型', name: 'type', index: 'TYPE', width: 80, formatter: function (value) {
                        return sysEnums.FAULT_TYPE[value];
                    }
                },
                {label: '类型', name: 'type', index: 'TYPE', width: 80, hidden: true},
                {label: '故障现象描述', name: 'faultAppear', index: 'FAULT_APPEAR', width: 80, hidden: true},
                {label: '设备小类ID', name: 'devTypeIdS', index: 'DEV_TYPE_ID_S', width: 80, hidden: true},
                {label: '设备中类ID', name: 'devTypeIdM', index: 'DEV_TYPE_ID_M', width: 80, hidden: true},
                {label: '设备大类ID', name: 'devTypeIdB', index: 'DEV_TYPE_ID_B', width: 80, hidden: true},
                // {label: 'id', name: 'id', index: 'ID', key: true, hidden: true},
            ]
        });
    });
    let vm = new Vue({
        el: '#rrapp',
        data: {
            showList: true,
            title: null,
            faultBase: {
                id: '',
            },
            ruleValidate: {
                name: [
                    {required: true, message: '名称不能为空', trigger: 'blur'}
                ]
            },
            q: {
                name: ''
            },
            TypeArray: enumsToList("FAULT_TYPE")
        },
        methods: {
            query: function () {
                vm.reload();
            },

            reload: function (event) {
                vm.showList = true;
                let page = $("#jqGrid").jqGrid('getGridParam', 'page');
                $("#jqGrid").jqGrid('setGridParam', {
                    postData: {'name': vm.q.name},
                    page: page
                }).trigger("reloadGrid");
                vm.handleReset('formValidate');
            }
            ,
        }
    })
    var getFaultInfo = function () {
        let result = getSelectedRowData("#jqGrid");
        var faultCode = result.faultCode;
        console.log(result)
        if (faultCode == null) {
            return false;
        } else {
            return result;
        }
    }
</script>
</body>
</html>